﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace XNAGuiLib.GuiLibResourceManager
{
    public class GuiResourceManager
    {
        #region Private Field - _game
        // private field for a game instance (needed to get a usable IServiceProvider object)
        private Game _game;
        #endregion

        #region Enumeration - ResourceManagerType
        /// <summary>
        /// enumeration for the different ResourceContentManager empedded in the XNAGuiLib (using prebuild/empedded .xnb files)
        /// </summary>
        public enum ResourceManagerType
        {
            /// <summary>
            /// ResourceManager for all Fonts used in the XNAGuiLib
            /// </summary>
            Font,
            /// <summary>
            /// ResourceManager for all 'default'-style related graphics used in the XNAGuiLib
            /// </summary>
            StyleDefault,
            /// <summary>
            /// ResourceManager for all 'horizons'-style related graphics used in the XNAGuiLib
            /// </summary>
            StyleHorizons,
            /// <summary>
            /// ResourceManager for all 'mac'-style related graphics used in the XNAGuiLib
            /// </summary>
            StyleMac
        }
        #endregion


        #region Constructor - GuiResourceManager(Game game)
        /// <summary>
        /// default constructor
        /// </summary>
        /// <param name="game">game instance to get the ServiceProvider from</param>
        private GuiResourceManager(Game game)
        {
            _game = game;
        }
        #endregion


        #region Method - Instance(Game game)
        private static GuiResourceManager _instance = null;
        /// <summary>
        /// gets the RManager instance
        /// </summary>
        public static GuiResourceManager Instance(Game game)
        {
            if (_instance == null)
                _instance = new GuiResourceManager(game);

            return _instance;
        }
        #endregion

        #region Method - Instance(Game game, RManagerType type)
        /// <summary>
        /// gets the RManager instance
        /// </summary>
        public static ResourceContentManager Instance(Game game, ResourceManagerType type)
        {
            switch (type)
            {
                // --------------------------------------------
                // case: FontManager type to return
                case ResourceManagerType.Font:
                    return Instance(game).FontManager;
                // --------------------------------------------
                // case: StyleDefaultManager type to return
                case ResourceManagerType.StyleDefault:
                    return Instance(game).StyleDefaultManager;
                // --------------------------------------------
                // case: StyleHorizonsManager type to return
                case ResourceManagerType.StyleHorizons:
                    return Instance(game).StyleHorizonsManager;
                // --------------------------------------------
                // case: StyleHorizonsManager type to return
                case ResourceManagerType.StyleMac:
                    return Instance(game).StyleMacManager;
                // --------------------------------------------
                // case: StyleDefaultManager type to return
                default:
                    return Instance(game).StyleDefaultManager;
            }
        }
        #endregion


        #region Static Field - FontManager
        private ResourceContentManager _fontManager = null;
        /// <summary>
        /// gets the default FontManager object for the XNAGuiLib
        /// </summary>
        public ResourceContentManager FontManager
        {
            get
            {
                if (_fontManager == null)
                    _fontManager = new ResourceContentManager(_game.Content.ServiceProvider, global::XNAGuiLib.Properties.Fonts.ResourceManager);

                return _fontManager;
            }
        }
        #endregion

        #region Static Field - StyleDefaultManager
        private ResourceContentManager _styleDefaultManager = null;
        /// <summary>
        /// gets the default DefaultManager object for the XNAGuiLib
        /// </summary>
        public ResourceContentManager StyleDefaultManager
        {
            get
            {
                if (_styleDefaultManager == null)
                    _styleDefaultManager = new ResourceContentManager(_game.Content.ServiceProvider, global::XNAGuiLib.Properties.StyleDefault.ResourceManager);

                return _styleDefaultManager;
            }
        }
        #endregion

        #region Static Field - StyleHorizonsManager
        private ResourceContentManager _styleHorizonsManager = null;
        /// <summary>
        /// gets the default HorizonsManager object for the XNAGuiLib
        /// </summary>
        public ResourceContentManager StyleHorizonsManager
        {
            get
            {
                if (_styleHorizonsManager == null)
                    _styleHorizonsManager = new ResourceContentManager(_game.Content.ServiceProvider, global::XNAGuiLib.Properties.StyleHorizons.ResourceManager);

                return _styleHorizonsManager;
            }
        }
        #endregion

        #region Static Field - StyleMacManager
        private ResourceContentManager _styleMacManager = null;
        /// <summary>
        /// gets the default MacManager object for the XNAGuiLib
        /// </summary>
        public ResourceContentManager StyleMacManager
        {
            get
            {
                if (_styleMacManager == null)
                    _styleMacManager = new ResourceContentManager(_game.Content.ServiceProvider, global::XNAGuiLib.Properties.StyleMac.ResourceManager);

                return _styleMacManager;
            }
        }
        #endregion


        #region Static Field - Vista_Graphit
        private ResourceContentManager _vista_graphit = null;
        /// <summary>
        /// gets the default vista graphit object for the XNAGuiLib
        /// </summary>
        public ResourceContentManager Vista_Graphit
        {
            get
            {
                if (_vista_graphit == null)
                    _vista_graphit = new ResourceContentManager(_game.Content.ServiceProvider, global::XNAGuiLib.Properties.Vista_Graphit.ResourceManager);

                return _vista_graphit;
            }
        }
        #endregion
    }
}
